package edu.java.lectures.lec15.comparator;

import java.util.Comparator;

public class PersonAgeComparator implements Comparator<Person> {

    @Override
    public int compare(Person p1, Person p2) {
	if (p1 == null) {
	    throw new IllegalArgumentException("Illegal argument p1: null.");
	}
	if (p2 == null) {
	    throw new IllegalArgumentException("Illegal argument p2: null.");
	}
	int p1Age = p1.getAge();
	int p2Age = p2.getAge();

	return (p1Age - p2Age);
    }

}
